import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ContactsVO, ContactsForm, ContactsQuery } from '@/api/workorder/contacts/types';

/**
 * 查询通讯录列表
 * @param query
 * @returns {*}
 */

export const listContacts = (query?: ContactsQuery): AxiosPromise<ContactsVO[]> => {
  return request({
    url: '/workorder/contacts/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询通讯录详细
 * @param id
 */
export const getContacts = (id: string | number): AxiosPromise<ContactsVO> => {
  return request({
    url: '/workorder/contacts/' + id,
    method: 'get'
  });
};

/**
 * 新增通讯录
 * @param data
 */
export const addContacts = (data: ContactsForm) => {
  return request({
    url: '/workorder/contacts',
    method: 'post',
    data: data
  });
};

/**
 * 修改通讯录
 * @param data
 */
export const updateContacts = (data: ContactsForm) => {
  return request({
    url: '/workorder/contacts',
    method: 'put',
    data: data
  });
};

/**
 * 删除通讯录
 * @param id
 */
export const delContacts = (id: string | number | Array<string | number>) => {
  return request({
    url: '/workorder/contacts/' + id,
    method: 'delete'
  });
};
